//
//  JCError.h
//  Victor
//
//  Created by Guo.JC on 17/3/7.
//  Copyright © 2017年 coollang. All rights reserved.
//

#import <Foundation/Foundation.h>

/**
 *  Error domains.
 */
extern NSString *const DTModelValidationErrorDomain;
extern NSString *const DTDuoTracAPIErrorDomain;

/**
 *  Error codes for model validation domain.
 */
typedef NS_ENUM(NSUInteger, DTModelValidationErrorCode) {
    DTModelValidationErrorCodeEntryMissing = 0,
    DTModelValidationErrorCodeInvalidEmail,
    DTModelValidationErrorCodeUserPasswordIncorrect,
    DTModelValidationErrorCodeUserPasswordsNotMatch,
    DTModelValidationErrorCodeUserPasswordTooShort
};

/**
 *  Error codes for DuoTrac API consumption domain.
 */
typedef NS_ENUM(NSUInteger, DTDuoTracAPIErrorCode) {
    // General error codes
    DTDuoTracAPIErrorCodeSystemError = 500,
    DTDuoTracAPIErrorCodeUnauthorized = 401,
    DTDuoTracAPIErrorCodeUnreachable = 404,
    // User-related error codes
    DTDuoTracAPIErrorCodeUserInvalidCredentails = 1100,
    DTDuoTracAPIErrorCodeUserMissingRequiredFields = 1000,
    DTDuoTracAPIErrorCodeUserEmailExists = 1001,
    DTDuoTracAPIErrorCodeUserPasswordTooShort = 1002,
    DTDuoTracAPIErrorCodeUserEmailInvalid = 1003,
    DTDuoTracAPIErrorCodeUserEmailNotPresent = 1004,
    DTDuoTracAPIErrorCodeDuplicateData = 2002
};


@interface NSError (Intialization)

+ (NSError *)errorWithDomain:(NSString *)aDomain
                        code:(NSInteger)aCode;

+ (NSError *)errorWithDomain:(NSString *)aDomain
                        code:(NSInteger)aCode
        localizedDescription:(NSString *)aDescription;

@end

@interface NSError (Message)

- (NSString *)errorMessage;

@end
